import pymysql


class DBUtils:
    host = "localhost"
    port = 3306
    user = "root"
    password = "root"
    database = "finance"

    def update(self, sql):
        con = pymysql.connect(host=self.host, port=self.port, user=self.user, password=self.password, database=self.database)
        cursor = con.cursor()
        cursor.execute(sql)
        con.commit()
        con.close()
        cursor.close()

    def select(self, sql):
        con = pymysql.connect(host=self.host, port=self.port, user=self.user, password=self.password, database=self.database)
        cursor = con.cursor()
        cursor.execute(sql)
        con.commit()
        data = cursor.fetchall()
        con.close()
        cursor.close()
        return data
